<!doctype html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../assert_selection.js"></script>
<script>
    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>|Two</div></div>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                'One|Two',
            '</div>',
        ].join('')),
        'Removing inner DIVs');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>|Two</div>Three</div>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                'One|TwoThree<br>',
            '</div>',
        ].join('')),
        'Removing DIVs and insert BR');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>|Two<br></div>Three</div>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                '<div>One|Two<br>Three</div>',
            '</div>',
        ].join('')),
        'Replace DIV+BR to BR');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>|Two<br>\n</div>Three</div>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                '<div>One|Two<br>Three</div>',
            '</div>',
        ].join('')),
        'Replace DIV+BR to BR with newline');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>|Two<div>Three</div></div>Four</div>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                'One|Two<div><div>Three</div></div>Four<br>',
            '</div>',
        ].join('')),
        'Keep DIV nesting');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>|Two<div>Three<br></div></div>Four</div>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                'One|Two<div><div>Three<br></div></div>Four<br>',
            '</div>',
        ].join('')),
        'Keep DIV nesting and BR');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>|Two<br><div>Three<br></div></div>Four</div>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                '<div>One|Two<div><div>Three<br></div></div>Four</div>',
            '</div>',
        ].join('')),
        'Replace BR to DIV');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>\n|Two<div>Three</div></div>Four</div>',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                'One|Two<div><div>Three</div></div>Four<br>',
            '</div>',
        ].join('')),
        'Keep DIV nesting with newline');

    test(() => assert_selection(
        [
            '<div contenteditable>',
                '<div>One<div>Two<br><div>|Three<br></div>Four</div>Five',
            '</div>',
        ].join(''),
        'delete',
        [
            '<div contenteditable>',
                '<div>One<div>Two|Three<br>Four</div>Five</div>',
            '</div>',
        ].join('')),
        'Merge "Two" and "Three"');
</script>
